package com.chezhujie.www.service;

import com.chezhujie.www.domain.Czjpayorder;
import com.chezhujie.www.persistence.CzjpayorderMapper;
import com.sys.core.exception.ClassCheckException;
import com.sys.user.base.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


/**
 * 支付订单
 * Created by 汤伟杰 on 2017/5/23.
 */
@Service
public class CzjpayorderService extends BaseService<Czjpayorder> {
    @Autowired
    private CzjpayorderMapper czjpayorderMapper;

    @Autowired
    public void setBaseMapper(CzjpayorderMapper czjpayorderMapper) {
        this.baseMapper = czjpayorderMapper;
    }


    public void checkEntity(Czjpayorder czjpayorder) throws ClassCheckException {
        if(czjpayorder.getPayorderId()!=null&&czjpayorder.getPayorderId().length()>19){
            throw new ClassCheckException("支付订单主键不能超过19个字符");
        }
        if(czjpayorder.getPayorderno()!=null&&czjpayorder.getPayorderno().length()>32){
            throw new ClassCheckException("支付订单支付订单号不能超过32个字符");
        }
    }
    public void checkListEntity(List<Czjpayorder> listCzjpayorder) throws ClassCheckException {

        for (Czjpayorder czjpayorder : listCzjpayorder) {
            checkEntity(czjpayorder);
        }

    }

    public Map<String,Object> getOrderedByNo(String orderNo) {
        return czjpayorderMapper.getOrderedByNo(orderNo);
    }
}
